package net.huashitong.question.dao;

import com.sirdc.modules.core.dao.GenericQuery;
import com.sirdc.modules.core.dao.StringDao;
import com.sirdc.modules.utils.StringUtils;
import net.huashitong.question.entity.Coordinate;
import net.huashitong.question.filter.CoordinateFilter;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class CoordinateDao extends StringDao<Coordinate> {
    public List<Coordinate> queryAllCoordinate(CoordinateFilter filter){
        GenericQuery query = createQuery("obj");
        //查询所有问题
        return query.listResult(filter);
    }
    public List<Coordinate> queryCoordinate(CoordinateFilter filter){
        GenericQuery query = createQuery("obj");

        if(StringUtils.isNotBlank(filter.getSysId()))
            query.append(" and sysId =:sysId").setParam("sysId",filter.getSysId());
        if(StringUtils.isNotBlank(filter.getProblemName()))
            query.append(" and problemName like:problemName").setParam("problemName",
                    StringUtils.getLikewords(filter.getProblemName()));
        if(StringUtils.isNotBlank(filter.getIndustryId()))
            query.append(" and industryId =:industryId").setParam("industryId",filter.getIndustryId());
        if(StringUtils.isNotBlank(filter.getIndustryName()))
            query.append(" and industryName like:industryName").setParam("industryName",
                    StringUtils.getLikewords(filter.getIndustryName()));
        if(StringUtils.isNotBlank(filter.getIndustryDate()))
            query.append(" and industryDate =:industryDate").setParam("industryDate",filter.getIndustryDate());
        if(StringUtils.isNotBlank(filter.getBaseInfo()))
            query.append(" and baseInfo like:baseInfo").setParam("baseInfo",
                    StringUtils.getLikewords(filter.getBaseInfo()));
        if(StringUtils.isNotBlank(filter.getHelpInfo()))
            query.append(" and helpInfo like:helpInfo").setParam("helpInfo",
                    StringUtils.getLikewords(filter.getHelpInfo()));
        if(StringUtils.isNotBlank(filter.getDeptId()))
            query.append(" and deptId =:deptId").setParam("deptId",filter.getDeptId());
        if(StringUtils.isNotBlank(filter.getDeptName()))
            query.append(" and deptName like:deptName").setParam("deptName",
                    StringUtils.getLikewords(filter.getDeptName()));
        if(StringUtils.isNotBlank(filter.getResUser()))
            query.append(" and resUser like:resUser").setParam("resUser",
                    StringUtils.getLikewords(filter.getResUser()));
        if(StringUtils.isNotBlank(filter.getResPhone()))
            query.append(" and resPhone =:resPhone").setParam("resPhone",filter.getResPhone());
        if(StringUtils.isNotBlank(filter.getGroupCode()))
            query.append(" and groupCode =:groupCode").setParam("groupCode",filter.getGroupCode());
        if(StringUtils.isNotBlank(filter.getDeptName()))
            query.append(" and groupName like:groupName").setParam("groupName",
                    StringUtils.getLikewords(filter.getDeptName()));
        if(StringUtils.isNotBlank(filter.getInspectors()))
            query.append(" and inspectors like:inspectors").setParam("inspectors",
                    StringUtils.getLikewords(filter.getInspectors()));
        if(StringUtils.isNotBlank(filter.getPhones()))
            query.append(" and phones =:phones").setParam("phones",filter.getPhones());
        if(StringUtils.isNotBlank(filter.getUserId()))
            query.append(" and userId =:userId").setParam("userId",filter.getUserId());
        if(StringUtils.isNotBlank(filter.getSource()))
            query.append(" and source like:source").setParam("source",
                    StringUtils.getLikewords(filter.getSource()));

//        query.append(" and obj.aaa001='1'");
        return query.listResult(filter);
    }



}
